getFullText(GetRequest().id);
function GetRequest()
{
    var url = location.search;   //获取url中"?"符后的字串
    var theRequest = new Object();
    if (url.indexOf("?") != -1)
    {
        var str = url.substr(1);
        strs = str.split("&");
        for (var i = 0; i < strs.length; i++)
        {
            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
        }
    }
    return theRequest;
}
function getFullText(bid) {
    $.ajax({
        url: "./blogText?BID=" + bid,
        method: "GET",
        dataType: "json"
    }).done(function (result) {
        // 根据取得的博客内容生成页面
        var pics=result.pics.split(",");
        setHead(result.author,result.title,result.time);
        addItems(result.blog,pics);
        if(result.isManager=="false")
            $(".deleteButton").remove();
    }).fail(function (xhr, status) {
        console.log(status);
    });
}
function setHead(author,title,time) {
   $(".blogTitle").text(title);
    $("#author").text(author);
    $("#time").text(time);
}
function addItems(blog,pics) {
    for (var i = 0; i < blog.length; i++) {
        if(blog[i].type=="p")
        {
            var item= "<p>"+blog[i].content+"</p>";
        }
        if(blog[i].type=="img")
        {
            var item= "<div class=\"blog_img\">" +
                "<img src=\"/MySpace/blogsPic/" +pics[blog[i].content]+
                "\" style=\"max-width: 100%\">" +
                "</div>"
        }
        $(".content").eq(0).append(item);
    }
}
